precision mediump float;
uniform sampler2D u_texture;

uniform vec3 spotLight;
uniform vec4 LightDiffuseColor;
uniform vec4 LightSpecularColor;
uniform vec4 AmbientComponent;

varying vec3   v_Nomal;
varying vec2 v_uv; 
varying vec3   toEye;
void main()
{
	vec3 LightDirection=vec3(0.0,0.0,0.0)-spotLight;
	vec4 ObjColor  = texture2D(u_texture, v_uv);
	vec3 direction=normalize(LightDirection);
	vec4 DiffuseComponent = max(dot(v_Nomal, -direction), 0.0)* LightDiffuseColor;
	vec3 reflectVector = normalize((reflect(direction, v_Nomal)));
	vec4 SpecularComponent=pow(max(dot(reflectVector,toEye),0.0),16.0)* LightSpecularColor;
	vec4 FinalColor = (AmbientComponent * 0.3 + DiffuseComponent * (1.0 - 0.3)) * ObjColor + SpecularComponent;
	gl_FragColor=FinalColor;
}
